package com.ziyun.erp.web.modules.finance.controller;

import com.ziyun.erp.modules.finance.entity.FinanceReceiptsAccountEntity;
import com.ziyun.erp.modules.finance.service.FinanceReceiptsAccountService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 财务收款帐户
 *
 * @author gaosheng
 * @email 
 * @date 2018-08-10 15:13:27
 */
@RestController
@RequestMapping("finance/financereceiptsaccount")
public class FinanceReceiptsAccountController {
    @Autowired
    private FinanceReceiptsAccountService financeReceiptsAccountService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("finance:financereceiptsaccount:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = financeReceiptsAccountService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{fraId}")
    @RequiresPermissions("finance:financereceiptsaccount:info")
    public R info(@PathVariable("fraId") Integer fraId){
        FinanceReceiptsAccountEntity financeReceiptsAccount = financeReceiptsAccountService.selectById(fraId);

        return R.ok().put("financeReceiptsAccount", financeReceiptsAccount);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("finance:financereceiptsaccount:save")
    public R save(@RequestBody FinanceReceiptsAccountEntity financeReceiptsAccount){
        financeReceiptsAccountService.insert(financeReceiptsAccount);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("finance:financereceiptsaccount:update")
    public R update(@RequestBody FinanceReceiptsAccountEntity financeReceiptsAccount){
        ValidatorUtils.validateEntity(financeReceiptsAccount);
        financeReceiptsAccountService.updateAllColumnById(financeReceiptsAccount);//全部更新

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("finance:financereceiptsaccount:delete")
    public R delete(@RequestBody Integer[] fraIds){
        financeReceiptsAccountService.deleteBatchIds(Arrays.asList(fraIds));

        return R.ok();
    }

}
